package com.trickytriads.viewmodels
{
	import com.trickytriads.model.CardData;
	import com.trickytriads.model.datastore.CardDataStore;
	import com.trickytriads.viewmodels.interfaces.I_CardstoreViewModel;
	
	import mx.collections.ArrayCollection;

	/**
	 * Default implementation of the Cardstore viewmodel.  Contains static
	 * CardstoreControl objects whose visibility are dependent on whether
	 * the associated array is null or not.
	 **/
	public class CardstoreViewModel implements I_CardstoreViewModel
	{		
		
		[Inject]
		public var cardDataStore:CardDataStore;
		
		private var _cardstoreArrayCollection:ArrayCollection;
		
		public function init () : void 
		{
			cardstoreArrayCollection = cardDataStore.getCardList(0, 8);
		}
		
		
		// Bindable cardstoreArrayCollection
		[Bindable]
		public function get cardstoreArrayCollection ( ) : ArrayCollection
		{
			return _cardstoreArrayCollection;
		}
		
		public function set cardstoreArrayCollection(v:ArrayCollection):void
		{
			// Unset the cardstoreArrayCollection
			_cardstoreArrayCollection = null;
			
			// Set and refresh
			_cardstoreArrayCollection = v;		
			_cardstoreArrayCollection.refresh();
		}
		
	}
}